package com.example.hospital.controller;


import com.example.common.util.core.controller.BaseController;
import com.example.common.util.core.resultbody.AjaxResult;
import com.example.hospital.service.HospitalService;
import com.example.model.domain.entity.hospital.Hospital;
import com.example.model.vo.hospital.HospitalQueryVo;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(tags = "医院管理")
@RestController
@RequestMapping("/admin/hospital/hospital")
public class HospitalController extends BaseController {

    @Autowired
    private HospitalService hospitalService;


    //医院列表(条件查询分页)
    @ApiOperation("查询医院分页")
    @PostMapping("page/{pageNum}/{pageSize}")
    public AjaxResult getHospitalPage(@PathVariable Integer pageNum, @PathVariable Integer pageSize, HospitalQueryVo hospitalQueryVo) {
        PageInfo<Hospital> pageModel = hospitalService.getHospitalPage(pageNum,pageSize,hospitalQueryVo);
        return AjaxResult.success(pageModel);
    }


    @ApiOperation("更新医院上线状态")
    @PostMapping("update/hospitalStatus/{id}/{status}")
    public AjaxResult updateHospitalStatus(@PathVariable String id, @PathVariable Integer status) {
        Boolean aBoolean = hospitalService.updateHospitalStatus(id, status);
        return toAjax(aBoolean);
    }

    @ApiOperation("查询医院详情")
    @GetMapping("get/hospitalDetail/{id}")
    public AjaxResult getHospitalDetail(@PathVariable String id){
        Map<String, Object> hospitalMap = hospitalService.getHospitalDetailById(id);
        return AjaxResult.success(hospitalMap);
    }



}
